<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>配货清单列表</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table td {
			vertical-align: middle;
		}
		.footer {
			position:fixed; bottom:0; background:#ABABAB; width:100%; height:35px; line-height:32px; z-index:9999; opacity:1;
			filter:alpha(opacity=60); _bottom:auto; _width:100%; _position:absolute;text-align: right;
			_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-
			(parseInt(this.currentStyle.marginTop, 10)||0)-(parseInt(this.currentStyle.marginBottom, 10)||0)));
	    }
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			var nodeLen = $(".jbox-button-panel", top.document).length;
			$(".jbox-button-panel", top.document).eq(nodeLen-1).remove();
			$("#listForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function exportExcel(){
			var supplierId = $("#supplierId").val();
			top.$.jBox.defaults.top="27%";
			top.$.jBox.confirm("确认要导出配送指令明细数据吗？","系统提示",function(v,h,f){
				if(v=="ok"){
					$.ajax({
						type: 'post',
						url: '${ctx}/ivm/purchase/exportDistribution',
						data: 'supplierId='+supplierId+'&orderIds='+$("input[id='orderIds']").val(),
						dataType: 'json',
						success: function(data){
							if(data.status==200){
								document.location.href= '${ctx}/download?filePath='+URLencode(data.message);
							}else{
								showJBoxMess(data.message,"error");
							}
						},
						failure: function(){
							showJBoxMess("操作失败","error");
						}
					});
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
	</script>
</head>
<body>
<form:form id="inputForm" action="${ctx}/ivm/purchase/showDistributionOrder" method="post">
	<tags:message content="${message}"/>
	<input type="hidden" id="orderIds" name="orderIds" value="${orderIds }" />
	<div style="margin:10px 10px 50px 10px;">
		<div class="breadcrumb form-search">
			<label>供应商：</label>
			<select id="supplierId" name="supplierId" style="width: 150px;">
				<option value="">请选择</option>
				<c:forEach items="${supplierList}" var="supplier">
				<option value="${supplier.id }" <c:if test="${supplierId==supplier.id }">selected</c:if>>${supplier.name }</option>
				</c:forEach>
			</select>
			&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
		</div>
		<table id="contentTable" class="table table-bordered table-condensed">
			<thead>
				<tr>
					<th>商品编号</th>
					<th>商品名称</th>
					<th>商品规格</th>
					<th>配货数量</th>
				</tr>
			</thead>
			<tbody class="detailBody">
			<c:forEach items="${detailList}" var="detail" varStatus="vs">
				<tr class="detail">
					<td>${detail.product.code }</td>
					<td>${detail.product.name }</td>
					<td>${detail.product.assisTitle }</td>
					<td>${detail.buyNumber }${detail.product.productUnit.name }</td>
				</tr>
			</c:forEach>
			</tbody>
		</table>
	</div>
</form:form>
<div class="footer">
<input type="button" class="btn btn-primary" onclick="exportExcel()" value="导出" style="margin-right: 20px;"/>
</div>
</body>
</html>